import {Component, ViewChild} from '@angular/core';

import { HomePage }       from '../home/home';
import { PlatformsPage }  from '../home/platforms/platforms';
import { ActivityPage }   from '../activity/activity';
import { WalletPage }     from '../wallet/wallet';
import { MePage }         from '../me/me';

import { Tabs,Events}     from "ionic-angular";
import { NativeService }  from '../../service/NativeService';
import { HttpService }    from '../../service/httpService';
import { UserService }    from '../../service/userService';
@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

  tab1Root = HomePage;
  tab2Root = ActivityPage;
  tab3Root = WalletPage;
  tab4Root = MePage;
  tab5Root = PlatformsPage;
  private indexPage:number = 0;
  @ViewChild('myTabs') tabs :Tabs;
  constructor(public event:Events,
              public http:HttpService,
              public user:UserService,
              public nat:NativeService) {
  }

  select(index){
    if (index == 2){

      if(!this.user.isLogin){
        this.tabs.select(this.indexPage);
        this.event.publish("loginAction",{});
      }

    }else {
      this.indexPage = index;
    }
  }
}
